<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_order', function (Blueprint $table) {
            $table->increments('id')->comment("ID");
            $table->integer('user_id')->comment("用户ID");
            $table->string('order_sn',50)->comment('订单编号');
            $table->unsignedDecimal('goods_amount',10,2)->default(0.00)->comment('商品金额');
            $table->unsignedDecimal('order_amount',10,2)->default(0.00)->comment('订单金额');
            $table->unsignedDecimal('pay_amount',10,2)->default(0.00)->comment('支付金额');
            $table->decimal('coupon_amount',10,2)->default(0.00)->comment('优惠金额');
            $table->unsignedTinyInteger('coupon_id')->nullable()->comment('优惠券ID');
            $table->unsignedInteger('pay_id')->nullable()->comment('支付ID');
            $table->string("username",50)->comment("收货人");
            $table->string("phone",20)->comment("联系电话");
            $table->string("address",200)->comment("收货地址");
            $table->string('shipping_company',50)->default('')->nullable()->comment('物流公司');
            $table->string('shipping_code',50)->default('')->nullable()->comment('物流单号');
            $table->integer('order_status')->default(0)->comment('订单状态：-1(已取消)0(默认):未付款;1:已付款;2:已发货;3:已收货;');
            $table->dateTime("order_time")->comment("下单时间");
            $table->dateTime('pay_time')->nullable()->comment('支付时间');
            $table->dateTime('send_time')->nullable()->comment('发货时间');
            $table->dateTime('finished_time')->nullable()->comment('订单完成时间');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_order');
    }
}
